<style scoped>
.wraper {
    padding: 0 30px;
}

.search {
    padding-bottom: 20px;
}

.search span {
    color: #68777c;
    font-weight: bold;
    padding-right: 18px;
}

.search button {
    background-color: #00a8f7;
    color: #fff;
    margin-left: 8px;
}

.top {
    margin-bottom: 20px;
    border-top: 1px dashed #cccccc;
}

.detail {
    border-top: 1px dashed #cccccc;
}

.wraper .headline {
    position: relative;
    font-size: 12px;
    color: #303134;
    font-weight: bold;
    margin: 10px 0;
    line-height: 32px;
    height: 32px;
}

.wraper .add-agent {
    position: absolute;
    top: 0px;
    right: 30px;
    background-color: #348bf2;
    color: #fff;
}

.iconfont {
    font-size: 14px;
}

.red-font {
    color: #ff1f1f;
}

/* 分页 start */

/* .page {
    margin: 20px 0;
} */
.ivu-page {
    padding-bottom: 150px;
} 

/* 分页 end */

.fixed-bottom{
    padding-left: 20px;
    padding-right: 20px;
    height: 80px;
    line-height: normal !important;
    position: fixed;
    left: 210px;
    right: 0;
    bottom: 0;
    z-index: 999;
    text-align: center;
    background-color: rgb(255, 255, 255);
    box-shadow: 0px 0px 9px 0px rgba(0, 0, 0, 0.28);
}
.sidehide{
    left: 75px;
}

.ivu-page {
    padding-bottom: 150px;
}

</style>
<style>
.nopass{
    color: #ed3f14;
}
.pass{
    color: #19be6b;
}
.hold{
    color: #ff9900;
}

/* 自定义modal start */
.team .ivu-modal-body {
    padding: 0px;
    background-color: #fff;
}

.team .ivu-modal-content:after {
    content: '';
    display: block;
    clear: both;
}

.team .ivu-modal-content {
    zoom: 1;
    background-color: #cfeaf8;
}

.team .ivu-modal-body {
    float: left;
    width: 67%;
    padding: 10px;
}

.team .ivu-modal-footer {
    float: left;
    width: 33%;
    text-align: center;
    padding: 0 14px;
}

.team .check-info, .team .promote-info{
    margin-bottom: 10px;
    position: relative;
    min-height:195px;
}

.team .check-standard .info .title {
    width: 7.7%;
    height: 100%;
    background-color: #4074e1;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    position: absolute;
    top: 0;
    bottom: 0; 
    overflow: hidden;
    padding-top: 5%;
    /* padding-top: 48px; */
}

.team .check-standard .promote-info.info .title {
    /* height: 425px; */
    /* padding-top: 150px; */
}

.title-div{
    /* top:50%;
    transform:translateY(50%); */
}

.team .check-standard .info .content {
    width: 92.3%;
}

.team .ivu-table-tbody {
    font-size: 12px;
}

.team .ivu-table-tbody td.condition {
    background-color: #f0f0f0;
    font-weight: bold;
    text-align: left;
    padding-left: 10px;
}

.team .ivu-table-header .condition {
    text-align: left;
    padding-left: 10px;
}

.team .ivu-table-header .ivu-table-column-center {
    background-color: #e4eaec;
    border-right: 1px solid #d6dfe2;
    border-bottom: 1px solid #d6dfe2;
}

.team .ivu-table-tbody .ivu-table-column-center {
    border-bottom: 1px solid #d6dfe2;
    border-bottom: 1px solid #d6dfe2;
}

.team .current-analyze {
    text-align: left;
    margin-bottom: 45px;
}

.team .current-analyze h5 {
    font-size: 16px;
    font-weight: bold;
    line-height: 60px;
}

.team .current-analyze .ivu-col-span-12 {
    background-color: #fff;
    height: 48px;
    line-height: 48px;
    padding-left: 20px;
    font-size: 12px;
}

.team .current-analyze .ivu-row {
    border-top: 1px solid #cfeaf8;
}

.team .current-analyze .ivu-row:first-child {
    border-top: none;
}

.team .current-analyze .ivu-col-span-12:first-child {
    border-right: 1px solid #cfeaf8;
    font-weight: bold;
}

.team .current-analyze .c1 {
    color: #ff855f;
}

.team .current-analyze .c2 {
    color: #08c111;
}



</style>



<template>
<!-- // basicLaw_lists -->
    <div class="basicLaw_lists">
        <product-title></product-title>
        <div class="wraper">
            <!-- <div class="search  common-box-body">
                <Row>
                    <h3 class="search-h3 huang" >
                        快速搜索
                    </h3>
                    <Form  :model="searchForm" >
                        <Col :xs="24" :sm="12" :md="12" :lg="5">
                            <Form-item>
                                <Input v-model="searchForm.name" placeholder="请输入代理人姓名"></Input>
                            </Form-item>
                        </Col>
                        <Col :xs="24" :sm="12" :md="12" :lg="5">
                            <Form-item>
                                <Input v-model="searchForm.job_code" placeholder="请输入代理人工号"></Input>
                            </Form-item>
                        </Col>
                        <Col :xs="24" :sm="12" :md="12" :lg="4">
                            <Form-item>
                                <Select v-model="searchForm.rank" placeholder='请选择级别'>
                                    <Option value="0" >全部</Option>
                                    <Option :value="item.id" v-for="item in rankList" :key="item.id" >{{item.name}}</Option>
                                </Select>
                            </Form-item>
                        </Col>
                        <Col :xs="24" :sm="12" :md="12" :lg="4">
                            <Form-item>
                                <Select v-model="searchForm.promote" placeholder='请选择晋升结果'>
                                    <Option value="0" >全部</Option>
                                    <Option value="1" >晋升</Option>
                                    <Option value="2" >未达到</Option>
                                </Select>
                            </Form-item>
                        </Col>
                        <Col :xs="24" :sm="12" :md="12" :lg="4">
                            <Form-item>
                                <Select v-model="searchForm.keep" placeholder='请选择维持结果'>
                                    <Option value="0" >全部</Option>
                                    <Option value="1" >维持</Option>
                                    <Option value="2" >降级</Option>
                                </Select>
                            </Form-item>
                        </Col>
                        <Col :xs="24" :sm="24" :md="24" :lg="2" >
                            <Form-item>
                                <Button class="fr" @click='search'>查询</Button>
                            </Form-item>
                        </Col>
                    </Form>
                </Row>
            </div> -->
            <div class="detail">
                <div class="headline">
                                
                </div>
                <div class="clearfix">
                    <div class="table-theme highlight_table">
                        <Table :loading="tableloading" ref="selection" @on-selection-change="selectchange"
                        size="large" @on-current-change="tableCurrentChange($event)" stripe  border :columns="columns_employee" :data="data_employee"></Table>
                    </div>
                </div>
            </div>
        </div>
        <Modal v-model="showAddModal2" ok-text="提交" :mask-closable='closeable2' width="600" :title="this.eid_arr.length>1?'批量转正':'个人转正'"  @on-ok="add2" @on-cancel="cancel2" :loading="loading2" class-name="common-box-body">
            <Row>
                <Col>
                    <Form :model="org" ref="org" :rules="ruleValidate">
                        <div style="margin-bottom:20px;">提示:&nbsp;&nbsp;您选取了本页中的<span style="color:red;">{{count}}</span>条数据,当前进行的操作是:<span style="color:blue;">员工转正</span></div>
                        <FormItem label="转正日期" prop="promotion_timeall">
                              <DatePicker type="date" placeholder="请选择日期" v-model="org.promotion_timeall"   @on-change="datachange($event,org,'promotion_time')"></DatePicker>
                          </FormItem>
                    </Form>
                </Col>
            </Row>
        </Modal>
        <div :class="slidetoggle?'fixed-bottom':'fixed-bottom sidehide' ">
            <Row class="pro-pagesize">
                <Col :md="24" :lg="16">
                    <!-- <Button type="primary" :disabled="tableaction" @click="tableEdit" size="large" class="fl mr10">编辑</Button> -->
                    <Button type="success" :disabled="tableactiona" @click="positive" size="large" class="fl mr10">转正</Button>
                    <Button type="success" :disabled="tableactions" @click="positiveall" size="large" class="fl mr10">批量转正</Button>
                </Col>
                <!-- <Col :md="24" :lg="8" class="tRight">
                    <Page ref="pages" :current="currentpage" :total="employeeTotal" show-total show-sizer :page-size="pagesize" @on-change="pageChange" @on-page-size-change="pageSizeChange" placement="top" class="page"></Page>
                </Col> -->
            </Row>
        </div>

    </div>
</template>

<script>
import productTitle from '../../components/productTitle'
import {set_regular_all,get_regular_emp,get_policys} from '../../api/org'
export default {
    data() {

        return {
            showAddModal2:false,
            closeable2:false,
            loading2:true,
            eid_arr:[],
            count:0,
            org:{ 
                promotion_time:"",
                promotion_timeall:"",
                },
            tableloading:true,
            tableaction:true, 
            currentpage:1,
            tableactiona:true,//批量转正的按钮
            tableactions:true,//批量转正的按钮
            // currentRow:{},
            page: 1,
            pagesize: 10,
            employeeTotal: 0,
            columns_employee: [
                {
                    type: 'selection',
                    width: 60,
                    align: 'center'
                },
                {
                    title: '员工姓名',
                    key: 'name',
                    align: 'center',
                },
                {
                    title: '职级',
                    key: 'rank',
                    align: 'center',
                },
                {
                    title: '累计FYC',
                    key: 'money',
                    align: 'center',
                },
                {
                    title: '入司时间',
                    key: 'join_time',
                    align: 'center',
                },
            ],
            data_employee: [

            ],
            ruleValidate: {
                promotion_timeall:[
                    { required: true, message: '日期不能为空' }
                ],
            },
        }
    },
    components: {
        productTitle
    },
    computed: {
        slidetoggle(){
            return this.$store.state.sildeshow
        },
    },
    created() {
        this.getList()   
    },
    methods: {
        //时间转换
        datachange(date,obj,param){
            obj[param] = date;
            console.log(obj[param],"当前点击的是哪个日期")
        },
        add2(){
            this.$refs['org'].validate((valid) => {
                if (valid) { 
                    this.org.eid_arr =  this.eid_arr
                    console.log(this.org,"提交表单")
                    new Promise((resolve, reject) => {
                        set_regular_all(this.org).then(response => {
                            if (response.data.err == 0) {
                                this.showAddModal2 = false;
                                this.$Message.success('转正成功!');
                                this.$refs["org"].resetFields();
                                this.getList()
                            } else {
                                this.$Message.error(response.data.info);
                                this.loading2 = false;
                                this.showAddModal2 = true;
                            }
                            resolve();
                        }).catch(error => {
                            reject(error);
                        });
                    });            
                } else {
                    // 通过loading来阻止modal隐藏，然后手动修改loading来充值确定按钮
                    setTimeout(() => {
                        this.loading2 = false;
                        this.$nextTick(() => {
                            this.loading2 = true;
                            this.showAddModal2 = true;   
                        });
                    }, 2000);
                }    
            })  
        
        },
        cancel2 () {
            this.$refs['org'].resetFields(); 
        },
         selectchange(val){
            var _this = this;
            console.log(val,"333333333")
            if(val.length==1){
                _this.tableactiona=false;
                _this.tableactions=true;
            }else if(val.length>1){
                _this.tableactiona=true;
                _this.tableactions=false;
            }else{
               _this.tableactiona=true;
                _this.tableactions=true; 
            }
            _this.eid_arr=[];
            for(var i in val){
                if(!_this.eid_arr.includes(val[i].eid)){
                    _this.eid_arr.push(val[i].eid)
                }
            }
            _this.count = _this.eid_arr.length;
            console.log(_this.eid_arr,"_this.policy_mids.....  ")
        },
        // 转正
        positive(){
            var _this = this;
            _this.showAddModal2 = true;
        },
        //批量转正
        positiveall(){
            var _this = this;
             _this.showAddModal2 = true;
        },
        // 搜索
        search() {
            this.getList()           
        },
        // 获取员工列表
        getList() {
            this.tableloading = true;
            this.tableaction = true;
            new Promise((resolve, reject) => {
                get_regular_emp().then(response => {
                    console.log(response.data);;    
                    this.tableloading = false
                    if (response.data.err == 0) {
                        this.data_employee = response.data.data;
                        // alert(this.data_employee.length)
                        // this.employeeTotal = response.data.data.total;
                    } else {
                        this.$Message.error(response.data.info);
                    }
                    resolve();
                }).catch(error => {
                    this.tableloading = false
                    reject(error);
                });
            });
        },


        // 页码改变
        pageChange(page) {
            this.page = page
            this.getList()
        },
        // 每页条数改变
        pageSizeChange(pagesize) {
            this.pagesize = pagesize
            this.getList();
        },
    }
}
</script>
